package 第六周;

/*
 * @author  YxinMiracle
 * @date  2022-05-05 19:27
 * @Gitee: https://gitee.com/yxinmiracle
 */

public class 最长递增子序列 {

    public int lengthOfLIS(int[] nums) {
        int n = nums.length;
        int[] f = new int[n];
        int ans = 0;
        for (int i = 0; i < n; i++) {
            f[i] = 1;
        }

        for (int i = 1; i < n; i++) {
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]){
                    f[i] = Math.max(f[i],f[j]+1);
                    ans = Math.max(ans,f[i]);
                }
            }
        }
        return ans;
    }

}
